import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/css/global.css'
import './assets/fonts/iconfont.css'
import axios from 'axios'

import VideoPlayer from 'vue-video-player'
import 'video.js/dist/video-js.css'
Vue.use(VideoPlayer)

// import VueNativeSock from 'vue-native-websocket'

Vue.use(ElementUI)

Vue.config.productionTip = false

Vue.prototype.$http = axios
Vue.prototype.$aimPath = 'http://8.131.93.118:8082'
axios.defaults.baseURL = 'http://8.131.93.118:8082'
new Vue({
  router,
  axios,
  render: h => h(App)
}).$mount('#app')

router.beforeEach((to, from, next) => {
  // to 将要访问的路径
  // from 代表从哪个路径来的
  // next 是一个函数，表示放行

  if (to.path === '/login' || to.path === '/register') return next()

  // 获取token
  const selfInfo = window.sessionStorage.getItem('selfInfo')
  if (!selfInfo) return next('/login')
  next()
})
